package net.cyndeline.events.movement
import net.cyndeline.entitySystem.Event
import net.cyndeline.events.ModifyError

/**
 * Sent to an entity to move it from one position to another.
 * This is only done per request from the entity itself, not
 * as an external effect.
 */
trait MovementEvent extends Event {
  def start: (Int, Int)
  def stop: (Int, Int)
  def start_=(newStart: (Int, Int))
  def stop_=(newStop: (Int, Int))
}

class Movement extends MovementEvent with ModifyError {
  private var startPos = (0, 0)
  private var stopPos = (0, 0)
  
  override def start = startPos
  override def stop = stopPos
  override def start_=(newStart: (Int, Int)) { 
    modify("start", this)
    startPos = newStart
  }
  
  override def stop_=(newStop: (Int, Int)) {
    modify("stop", this)
    stopPos = newStop
  }
  
  override def copy = {
    val copy = new Movement()
    copy.start = start
    copy.stop = stop
    copy
  }
}